home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
PASSRC.ZIP
/
ENCAP1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-02-04
|
1KB
|
53 lines
(* Chapter 14 - Program 1 *)
program Encapsulation_1;
type
Box = object
length : integer;
width : integer;
constructor Init(len, wid : integer);
procedure Set_Data(len, wid : integer);
function Get_Area : integer;
end;
constructor Box.Init(len, wid : integer);
begin
length := len;
width := wid;
end;
procedure Box.Set_Data(len, wid : integer);
begin
length := len;
width := wid;
end;
function Box.Get_Area : integer;
begin
Get_Area := length * width;
end;
var Small, Medium, Large : Box;
begin
Small.Init(8,8);
Medium.Init(10,12);
Large.Init(15,20);
WriteLn('The area of the small box is ',Small.Get_Area);
WriteLn('The area of the medium box is ',Medium.Get_Area);
WriteLn('The area of the large box is ',Large.Get_Area);
end.
{ Result of execution
The area of the small box is 64
The area of the medium box is 120
The area of the large box is 300
}